home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 1 / Amiga Tools.iso / egs-tools / egs_demo-version / egs_devels / examples / beginner_gadgets / gadget1.c < prev    next >
C/C++ Source or Header  |  1994-06-06  |  2KB  |  76 lines

  1. /**************************************************************************
  2. *****                       Gadget Demo 1                             *****
  3. *****                                                                 *****
  4. *****                     by John J. Karcher                          *****
  5. *****                                                                 *****
  6. *****                       4 August 1992                             *****
  7. *****                       10 Jan 1993  mvk                          *****
  8. *****                                                                 *****
  9. **************************************************************************/
  10.  
  11. /*
  12.    This program opens up a window with a single gadget in it, using
  13.    egsgadbox.library.  It is not smart; it merely calls Delay() and
  14.    closes.
  15. */
  16.  
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <exec/types.h>
  20. #include <proto/all.h>
  21. #include <egs/egsintui.h>
  22. #include <egs/egsgadbox.h>
  23. #include <egs/proto/all.h>
  24.  
  25. struct EI_Window  *CreateWindow(void);
  26.  
  27. struct Library *EGSIntuiBase;
  28. struct Library *EGBBase;
  29.  
  30. struct EB_GadContextNode   *GadCon;
  31.  
  32.  
  33. struct EI_Window  *CreateWindow(void)
  34. {
  35.    struct EI_Window  *ret = NULL;
  36.    EB_GadBoxPtr      root;
  37.  
  38.    if (GadCon = EB_CreateGadContext(NULL, NULL, -1, -1))
  39.      {
  40.       if (root = EB_CreateTextAction(GadCon, "Useless", 1, EB_FILL_ALL))
  41.         {
  42.          if (EB_ProcessGadBoxes(GadCon, root))
  43.            {
  44.             GadCon->NewWin->Title = "EGS Gadget Demo 1";
  45.             GadCon->NewWin->Width = 200;
  46.             GadCon->NewWin->Height= 100;
  47.             GadCon->NewWin->Flags = EI_WINDOWCENTER;
  48.  
  49.             ret = EI_OpenWindow(GadCon->NewWin);
  50.            }
  51.         }
  52.      }
  53.  
  54.    return ret;
  55. }
  56.  
  57. main()
  58. {
  59.    struct EI_Window  *Win;
  60.  
  61.    if (EGSIntuiBase = OpenLibrary("egsintui.library", 0))
  62.      {
  63.       if (EGBBase = OpenLibrary("egsgadbox.library", 0))
  64.         {
  65.          if (Win = CreateWindow())
  66.            {
  67.             Delay(250);
  68.            }
  69.          if (Win) EI_CloseWindow(Win);
  70.          if (GadCon) EB_DeleteGadContext(GadCon);
  71.          CloseLibrary(EGBBase);
  72.         }
  73.       CloseLibrary(EGSIntuiBase);
  74.      }
  75. }
  76.